var t = require("../../utils/utils");

Component({
    data: {
        windowWidth: 0,
        windowHeight: 0,
        arr: [],
        duration: 5e3,
        animations: [],
        lefts: [],
        tops: [],
        widths: []
    },
    properties: {
        show: {
            type: Boolean,
            value: !0
        }
    },
    ready: function() {
        var i = this, a = getApp().globalData.systeminfo;
        t.isEmptyObject(a) ? wx.getSystemInfo({
            success: function(t) {
                i.setData({
                    windowWidth: t.windowWidth || t.screenWidth,
                    windowHeight: t.windowHeight || t.screenHeight
                });
            }
        }) : this.setData({
            windowWidth: a.windowWidth || a.screenWidth,
            windowHeight: a.windowHeight || a.screenHeight
        });
        var e = parseInt(100 * Math.random()) + 10, n = Array.apply(null, {
            length: e
        }).map(function(t, i) {
            return i + 1;
        });
        this.setData({
            arr: n
        });
    },
    methods: {
        dance: function(t) {
            for (var i = this, a = this.data.windowWidth, e = this.data.windowHeight, n = this.data.duration, o = [], s = [], r = [], h = [], d = 0; d < this.data.arr.length; d++) {
                s.push(Math.random() * a), r.push(-140), h.push(50 * Math.random() + 40);
                var w = wx.createAnimation({
                    duration: Math.random() * (n - 1e3) + 1e3
                });
                w.top(e).left(Math.random() * a).rotate(960 * Math.random()).step(), o.push(w.export());
            }
            this.setData({
                lefts: s,
                tops: r,
                widths: h
            });
            var u = setTimeout(function() {
                i.setData({
                    animations: o
                }), clearTimeout(u);
            }, 200), p = setTimeout(function() {
                t && t(), clearTimeout(p);
            }, n);
        }
    }
});